// ********任务模块路由配置*************
const misRoutes = ['approve'];
const misConfig = [];
for (const route of misRoutes) {
  const comObj = {
    path: `/mission/${route}`,
    name: `mis${route}`,
    component: () => import(`@/views/mission/${route}`)
  };
  misConfig.push(comObj);
}
// ********产品模块路由配置*************
const proRoutes = ['need', 'test', 'defect', 'risk'];
const proConfig = [];
for (const route of proRoutes) {
  const comObj = {
    path: `/product/${route}`,
    name: `pro${route}`,
    component: () => import(`@/views/product/${route}`)
  };
  proConfig.push(comObj);
}
// ********采购模块路由配置*************
const purRoutes = ['plan', 'order', 'price'];
const purConfig = [];
for (const route of purRoutes) {
  const comObj = {
    path: `/purchase/${route}`,
    name: `pur${route}`,
    component: () => import(`@/views/purchase/${route}`)
  };
  purConfig.push(comObj);
}
// ********库存模块路由配置*************
const invRoutes = [
  'overview', 'inbound', 'outbound', 'checkout',
  'allot', 'assembly', 'quantity', 'validity'
];
const invConfig = [];
for (const route of invRoutes) {
  const comObj = {
    path: `/inventory/${route}`,
    name: `inv${route}`,
    component: () => import(`@/views/inventory/${route}`)
  };
  invConfig.push(comObj);
}
// ********培训模块路由配置*************
const traRoutes = ['course', 'task', 'assign', 'record', 'lessons', 'library', 'report'];
const traConfig = [];
for (const route of traRoutes) {
  const comObj = {
    path: `/train/${route}`,
    name: `tra${route}`,
    component: () => import(`@/views/train/${route}`)
  };
  traConfig.push(comObj);
}
// ********管理模块路由配置*************
const manRoutes = ['staff', 'role', 'log', 'approve', 'materiel', 'store', 'provider', 'train', 'product', 'invoice', 'credential'];
const manChildRoutes = {
  product: ['definition', 'level', 'status', 'limit', 'trace', 'basic', 'risk'],
  invoice: ['purchase', 'sales'],
  credential: ['device', 'provider', 'personnel', 'register']
};
const manConfig = [];
for (const route of manRoutes) {
  const childList = manChildRoutes[route];
  const children = [];
  let comObj = null;
  if (childList) {
    for (const child of childList) {
      const childObj = {
        path: `/manage/${route}/${child}`,
        name: `man${route}${child}`,
        component: () => import(`@/views/manage/${route}/${child}`)
      };
      children.push(childObj);
    }
    comObj = {
      path: `/manage/${route}`,
      name: `man${route}`,
      component: () => import(`@/views/manage/${route}`),
      redirect: `/manage/${route}/${childList[0]}`,
      children
    };
  } else {
    comObj = {
      path: `/manage/${route}`,
      name: `man${route}`,
      component: () => import(`@/views/manage/${route}`),
    };
  }
  manConfig.push(comObj);
}
// ********配置模块路由配置*************
const conRoutes = ['data', 'code'];
const conChildRoutes = {
  data: ['organization', 'supply'],
  code: ['supply']
};
const conConfig = [];
for (const route of conRoutes) {
  // children 循环
  const childList = conChildRoutes[route];
  const children = [];
  for (const child of childList) {
    const childObj = {
      path: `/config/${route}/${child}`,
      name: `con${route}${child}`,
      component: () => import(`@/views/config/${route}/${child}`)
    };
    children.push(childObj);
  }
  // ************
  const comObj = {
    path: `/config/${route}`,
    name: `con${route}`,
    component: () => import(`@/views/config/${route}`),
    redirect: `/config/${route}/${childList[0]}`,
    children
  };
  conConfig.push(comObj);
}
// **********************************

export default {
  misConfig,
  proConfig,
  purConfig,
  invConfig,
  traConfig,
  manConfig,
  conConfig
};
